<template>
	<view>
		<view>
			<button type="primary" @click="sendMesg">提交</button>
		</view>
		<view>
			<button type="warn" @click="setData">数据存储</button>
		</view>
		<view>
			<button type="primary" @click="getData">获取存储数据</button>
		</view>
		<view>
			<button type="primary" @click="removeData">清除存储数据</button>
		</view>
		<view>
			<button type="warn" @click="setDataSync">同步数据存储</button>
		</view>
		<view>
			<button type="primary" @click="getDataSync">同步获取存储数据</button>
		</view>
		<view>
			<button type="warn" @click="removeDataSync">同步清除存储数据</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			sendMesg(){
				console.log("发送请求")
				uni.request({
					url:"http://localhost:8089/nsd_springbootserver/userinfo/addorupdateuser",
					data:{
						username:"张无忌",
						userpwd:"123456",
						useraddress:"武当山",
						usertel:"16587445888"
					},
					method:"POST",
					success(res) {
						console.log(res)
					}
				})
			},
			setData(){
				uni.setStorage({
					key:"keyId",
					data:100,
					success() {
						console.log("存储成功。。。")
					}
				})
			},
			getData(){
				uni.getStorage({
					key:"keyId",
					success(res){
						console.log(res)
					}
				})
			},
			removeData(){
				uni.removeStorage({
					key:"keyId",
					success() {
						console.log("移除成功")
					}
				})
			},
			setDataSync(){
				uni.setStorageSync("idSync",500)
				console.log("存储成功")
			},
			getDataSync(){
				console.log("获取缓存内容："+uni.getStorageSync("idSync"))
				
			},
			removeDataSync(){
				uni.removeStorageSync("idSync")
				console.log("移除成功")
			}
			
		}
	}
</script>

<style>

</style>
